<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>职责链</title>
</head>
<body>
<script>
    function laoban(xiangmujingli){
         if(xiangmujingli){
             this.xiangmujingli=xiangmujingli;
         };
    }
    laoban.prototype.write=function(php){
        this.xiangmujingli.write(php);
    };
    function xiangmujingli(coder){
        if(coder){
            this.coder=coder;
        }
    }
    xiangmujingli.prototype.write=function(php){
        this.coder.write(php);
    }
    function coder(php){
//        this.write(php);
    }
    coder.prototype.write=function(php){
        console.log('coding....'+php)
    }
    var begin=new laoban(new xiangmujingli(new coder()));
    begin.write('php');
</script>
</body>
</html>